//
//  RegisteredViewController.m
//  ConscienceWorldPorject
//
//  Created by 孙海琛 on 2019/11/28.
//  Copyright © 2019 孙海琛. All rights reserved.
//

#import "RegisteredViewController.h"
#import "LoginHeaderView.h"
#import "LoginViewCell.h"
#import "LoginModel.h"

@interface RegisteredViewController ()<UITableViewDataSource, UITableViewDelegate>
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (strong, nonatomic)LoginHeaderView *loginHeaderView;
@property (strong, nonatomic)LoginHeaderView *loginFooterView;

@property (nonatomic,strong)NSDictionary *titleDic;

@property (nonatomic,strong)NSMutableArray *arrayData;

@end

@implementation RegisteredViewController
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self changeBarWhiteOrBlack:YES];
    self.navigationBarAlphaMu = 0;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self addNavigationBackBtnWhite:nil];
    [self addNavigationTitle:@"个人注册" titleColor:[UIColor whiteColor]];
    [self createUI];
}
- (void)createUI{
    _tableView.contentInset = UIEdgeInsetsMake(-kSafeTopMargin, 0, 0, 0);
    _tableView.tableHeaderView = self.loginHeaderView;
    _tableView.tableFooterView = self.loginFooterView;
    NSArray * arrD = [Tool jsonFile:@"Login"];
    for (int i = 0; i<arrD.count; i++) {
        LoginModel *model = [LoginModel mj_objectWithKeyValues:arrD[i]];
        [self.arrayData addObject:model];
    }
    kWeakSelf;
    _loginFooterView.zhuceBlock = ^{
        NSLog(@"%@",weakSelf.arrayData);
    };
}
//禁止顶部弹动
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    if (scrollView == _tableView) {
        CGFloat offY = scrollView.contentOffset.y;
        if (offY < 0) {
            scrollView.contentOffset = CGPointZero;
        }
    }
}

#pragma mark -- UITableViewDataSource, UITableViewDelegate
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.arrayData.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    LoginViewCell *cell = (LoginViewCell *)[LoginViewCell tempTableViewCellWith:tableView indexPath:indexPath model:self.arrayData];
    cell.model = self.arrayData[indexPath.row];
    return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 40;
}
#pragma mark -- set
- (LoginHeaderView *)loginHeaderView
{
    if (!_loginHeaderView) {
        _loginHeaderView = [[NSBundle mainBundle]loadNibNamed:@"LoginHeaderView" owner:self options:nil].firstObject;
        _loginHeaderView.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_WIDTH/1.233);
    }
    return _loginHeaderView;
}
- (LoginHeaderView *)loginFooterView
{
    if (!_loginFooterView) {
        _loginFooterView = [[NSBundle mainBundle]loadNibNamed:@"LoginHeaderView" owner:self options:nil].lastObject;
        _loginFooterView.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_WIDTH/3.125);
    }
    return _loginFooterView;
}
- (NSMutableArray *)arrayData
{
    if (!_arrayData) {
        _arrayData = [NSMutableArray array];
    }
    return _arrayData;
}
@end
